﻿using System;
using Enyim.Caching;
using Ayatta.Contract;
using System.Web.Mvc;
using Web.Core.Security;
using Web.Seller.Models;

namespace Web.Seller.Controllers
{
    public class RefundController : BaseController
    {
        public RefundController(Lazy<IInfrastructureService> infrastructure, Lazy<IPassportService> passport, Lazy<IAccountService> account, Lazy<IStoreService> store, Lazy<ITradeService> trade, Lazy<IPlayService> play, Lazy<IMiscService> misc, Lazy<IExtraService> extra, IMemcachedClient memcachedClient) : base(infrastructure, passport, account, store, trade, play, misc, extra, memcachedClient)
        {
        }

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Detail(string param)
        {
            var identity = User.Identity.Identity();
            var model = new RefundControllerModel.Detail();

            var refund = Trade.Value.GetRefund(param, identity.Id,true);
            if (refund != null)
            {
                var orderItem = Trade.Value.GetOrderItem(refund.OrderItemId, identity.Id, false, true);
                model.OrderItem = orderItem;
            }
            model.Refund = refund;
            ViewBag.Sidebar = false;
            return View(model);
        }
    }
}
